﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Runtime.Remoting.Messaging;
using MessageCallAspect.Inspector;
using MessageCallAspect.Inspector.Request;
using MessageCallAspect.Inspector.MessageSink;
using System.Diagnostics;
using MessageCallAspect.Aspect.Log;

namespace MessageCallAspect.Aspect.Log
{
    public class LogMessageSink : SimpleMessageInspector
    {
        #region ctor

        public LogMessageSink(IModuleContext context, object target, IMessageSink nextSink)
            : base(context, target, nextSink)
        {  }

        #endregion

        protected override Exception OnException(IMessageRequest request, Exception ex)
        {
            Logger.Instance.Error(request.Target.GetType().Name, ex);
            //Console.WriteLine("LogMessageSink - OnException: " + ex);
            return base.OnException(request, ex);
        }

    }
}
